const Koa = require('koa')
const Router = require('koa-router')
const WxpayRouter = require('./router/wxpay')
const bodyParser = require('koa-bodyparser')
const views = require('koa-views')
const path = require('path')

const app = new Koa()

// 使用ctx.body解析中间件
app.use(bodyParser())

// 加载模板引擎
app.use(views(path.join(__dirname, './view'), {
  extension: 'ejs'
}))

const router = new Router()

router.use('/wxpay', WxpayRouter.routes())

app.use(router.routes())

app.use( async (ctx, next) => {
  ctx.body = 'hello'
})

app.listen(3333)